﻿using System;

namespace IFD2
{
    public partial class ClassAvailProducts : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                if (Session["ACL"].ToString().IndexOf("NA1") < 0 && Session["ACL"].ToString().IndexOf("IA2")<0)
                {
                    Response.Redirect("unauthorized.aspx");
                }

                if (Request.QueryString["flt_no"] != null)
                    hidFltNo.Value = Request.QueryString["flt_no"].Trim();
                else
                {
                    lblError.Text = "Illegal page call!";
                    return;
                }

                if (Request.QueryString["plan_id"] != null)
                    hidPlanID.Value = Request.QueryString["plan_id"].Trim();
                else
                    hidPlanID.Value = "*";

                if (Request.QueryString["flt_date"] != null)
                    hidFltDate.Value = Request.QueryString["flt_date"].Trim();
                else
                {
                    lblError.Text = "Illegal page call!";
                    return;
                }
                if (Request.QueryString["ori"] != null)
                    hidOri.Value = Request.QueryString["ori"].Trim();
                else
                {
                    lblError.Text = "Illegal page call!";
                    return;
                }
                if (Request.QueryString["des"] != null)
                    hidDes.Value = Request.QueryString["des"].Trim();
                else
                {
                    lblError.Text = "Illegal page call!";
                    return;
                }
                if (Request.QueryString["class"] != null)
                    hidClass.Value = Request.QueryString["class"].Trim();
                else
                {
                    lblError.Text = "Illegal page call!";
                    return;
                }

                GridView1.DataBind();
            }
        }

        protected void lbtnQuery_Click(object sender, EventArgs e)
        {
            GridView1.DataBind();
        }

        protected void btnTrip_Click(object sender, EventArgs e)
        {
            string key;
            string[] strArray;
            if (Request.Form["KEY"] == null)
            {
                lblError.Text = "Please select the product.";
                return;
            }
            key = Request.Form["KEY"];
            strArray = key.Split('|');
            if (strArray[0].IndexOf(Session["AIRLINE"].ToString().Trim()) < 0)
            {
                lblError.Text = "Can not view other airline product!";
                return;
            }
            Response.Redirect("FareSegments.aspx?fare_code=" + strArray[1]);
        }
        protected void btnRules_Click(object sender, EventArgs e)
        {
            string key;
            string[] strArray;
            if (Request.Form["KEY"] == null)
            {
                lblError.Text = "Please select the product.";
                return;
            }
            key = Request.Form["KEY"];
            strArray = key.Split('|');
            if (strArray[0].IndexOf(Session["AIRLINE"].ToString().Trim()) < 0)
            {
                lblError.Text = "Can not view other airline product!";
                return;
            }
            Response.Redirect("FareDescription.aspx?code=" + strArray[1]);
        }
        protected void btnOffices_Click(object sender, EventArgs e)
        {
            string key;
            string[] strArray;
            if (Request.Form["KEY"] == null)
            {
                lblError.Text = "Please select the product.";
                return;
            }
            key = Request.Form["KEY"];
            strArray = key.Split('|');
            if (strArray[0].IndexOf(Session["AIRLINE"].ToString().Trim()) < 0)
            {
                lblError.Text = "Can not view other airline product!";
                return;
            }
            Response.Redirect("FareOffices.aspx?code=" + strArray[1] + "&airline=" + Session["AIRLINE"].ToString());
        }
    }
}